<template>
  <div>
    <!--整个外层容器-->
    <el-container>
      <!--顶栏 -->
      <el-header class="layout-header">
        <h1>酷鲨商城管理系统</h1>
      </el-header>
      <!--下半部分-->
      <el-container class="layout-body">
        <!--下半部分左栏-->
        <el-aside class="layout-aside">
          <el-menu
              router
              :default-active="activeMenuItemPath"
              class="el-menu-vertical-demo"
              background-color="#304156"
              text-color="#fff"
              active-text-color="#fff"
              style="border-right: 0">
            <el-menu-item index="/sys-admin/index">
              <i class="el-icon-s-home"></i>
              <span>首页</span>
            </el-menu-item>

            <el-menu-item index="/login">
              <i class="el-alert--success"></i>
              <span>登录</span>
            </el-menu-item>

            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-s-tools"></i>
                <span>临时页面</span>
              </template>
              <el-menu-item index="/sys-admin/temp/admins/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加管理员</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/temp/admins/list">
                <i class="el-icon-s-operation"></i>
                <span>管理员列表</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/brands/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加品牌</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/brands/list">
                <i class="el-icon-s-operation"></i>
                <span>品牌列表</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/categories/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加类别</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/categories/list-by-parent">
                <i class="el-icon-s-operation"></i>
                <span>类别列表</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/album/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加相册</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/album/list">
                <i class="el-icon-s-operation"></i>
                <span>相册列表</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/attribute-template/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加属性模板</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/attribute-template/select">
                <i class="el-icon-s-operation"></i>
                <span>属性模板列表</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/temp/attributes/add-new">
                <i class="el-icon-circle-plus"></i>
                <span>添加属性</span>
              </el-menu-item>
              <el-menu-item index="/sys-admin/temp/attributes/list">
                <i class="el-icon-s-operation"></i>
                <span>属性列表</span>

              </el-menu-item>
            </el-submenu>

            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-s-goods"></i>
                <span>商品管理</span>
              </template>
              <el-menu-item index="3-1">
                <i class="el-icon-s-grid"></i>
                <span>SPU台账</span>
              </el-menu-item>

              <el-menu-item index="/sys-admin/product/spu/add-new-01">
                <i class="el-icon-circle-plus"></i>
                <span>新增SPU</span>
              </el-menu-item>

              <el-menu-item index="3-3">
                <i class="el-icon-picture"></i>
                <span>相册管理</span>
              </el-menu-item>

              <el-menu-item index="3-4">
                <i class="el-icon-s-unfold"></i>
                <span>商品类别</span>
              </el-menu-item>

              <el-menu-item index="3-5">
                <i class="el-icon-s-flag"></i>
                <span>属性模板</span>
              </el-menu-item>

              <el-menu-item index="3-6">
                <i class="el-icon-s-data"></i>
                <span>品牌管理</span>
              </el-menu-item>
            </el-submenu>

            <el-submenu index="3—7" >
              <template slot="title">
                <i class="el-icon-s-order"></i>
                <span>订单管理</span>
              </template>
            </el-submenu>

            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-s-ticket"></i>
                <span>营销管理</span>
              </template>
            </el-submenu>

            <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-s-shop"></i>
                <span>商家管理</span>
              </template>
            </el-submenu>

            <el-submenu index="6">
              <template slot="title">
                <i class="el-icon-s-check"></i>
                <span>权限管理</span>
              </template>
            </el-submenu>
          </el-menu>
        </el-aside>
        <!--下半部部分右栏-->
        <el-main class="layout-main">
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style>
.layout-header{
  background-color: #3499a8;
}
.layout-header h1{
  color: white;
  line-height: 60px;
}
.layout-body{
  position: absolute;
  top: 60px;
  bottom: 0;
  left: 0;
  right: 0;
}
.layout-aside{
  background-color: #304156;
}
.layout-main{
  background-color: #fff;
}
.layout-aside i{
  color: aqua !important;
}
.el-menu-item.is-active{
  background: #1e2634 !important;
}
</style>

<script>
export default {
  data() {
    return {
      activeMenuItemPath: ''
    }
  },
  created() {
    let jwt = localStorage.getItem("jwt");
    if (!jwt) {
      this.$router.push("/login")
    }
  },
  mounted() {
    let path = this.$router.currentRoute.path;
    if (path.startsWith('/sys-admin/product/spu/add-new-')) {
      this.activeMenuItemPath = '/sys-admin/product/spu/add-new-1';
    } else {
      this.activeMenuItemPath = path;
    }
  }
}
</script>

